/**
 * 组件类型
 */
export enum DiyCompType {
  base = 'base'
}

export const DiyCompTypeDataMap: Record<string, string> = {
  base: '基础组件'
}

/**
 * 组件样式
 */
export interface IStyle {
  position: string
  left: string
  top: string
  width: string
  height: string
  fontSize: string
  zIndex: number
  [key: string]: any
}

export class BaseStyle implements IStyle {
  position = 'absolute'
  left: string = '0'
  top: string = '0'
  width: string = '200px'
  height: string = 'auto'
  zIndex: number = 999
  fontSize: string = '16px'

  constructor(data?: Partial<IStyle>) {
    Object.assign(this, data || {})
  }
}

/**
 * 控制器
 */
export interface IControl {
  keepRatio: boolean
  rotatable: boolean
  [key: string]: any
}

export class BaseControl implements IControl {
  resizable = true
  draggable = true
  keepRatio = false
  rotatable = false

  constructor(data?: Partial<IControl>) {
    Object.assign(this, data || {})
  }
}

export interface IDiyBase {
  type: DiyCompType

  id: string

  componentName: string

  componentFunctionName: string

  data: Record<string, any>

  style: IStyle

  control: IControl
}
